atftp: add patch to fix build warning
authorFlorian Eckert <[email protected]>
Tue, 2 Sep 2025 12:11:29 +0000 (14:11 +0200)
committerFlorian Eckert <[email protected]>
Mon, 8 Sep 2025 07:20:43 +0000 (09:20 +0200)
This patch fixes the following compilation build warning:

logger.c:117:47: warning: format '%li' expects argument of type 'long int', but argument 7 has type
  117 |                fprintf(log_fp, "%s %s %s[%d.%li]: %s\n", time_buf, hostname,
      |                                             ~~^
      |                                               |
      |                                               long int
  118 |                        log_ident, getpid(), pthread_self(), message);
      |                                             ~~~~~~~~~~~~~~
      |                                             |
      |                                             pthread_t {aka struct __pthread *}
logger.c:124:47: warning: format '%li' expects argument of type 'long int', but argument 7 has type
  124 |                fprintf(stderr, "%s %s %s[%d.%li]: %s\n", time_buf, hostname,
      |                                             ~~^
      |                                               |
      |                                               long int
  125 |                        log_ident, getpid(), pthread_self(), message);
      |                                             ~~~~~~~~~~~~~~
      |                                             |
      |                                             pthread_t {aka struct __pthread *}

I have also submitted the change to the upstream project:
https://github.com/madmartin/atftp/pull/2

Signed-off-by: Florian Eckert <[email protected]>
net/atftp/patches/0002-Fix-pthread_t-format-warning-for-fprintf.patch [new file with mode: 0644]

diff --git a/net/atftp/patches/0002-Fix-pthread_t-format-warning-for-fprintf.patch b/net/atftp/patches/0002-Fix-pthread_t-format-warning-for-fprintf.patch
new file mode 100644 (file)
index 0000000..60b4c80
--- /dev/null
@@ -0,0 +1,50 @@
+From a9da732718bd917a50aa25a6ae59e791c2c30380 Mon Sep 17 00:00:00 2001
+From: Florian Eckert <[email protected]>
+Date: Tue, 2 Sep 2025 13:53:05 +0200
+Subject: [PATCH] Fix pthread_t format warning for fprintf
+
+This change fixes the following compilation build warning:
+
+logger.c:117:47: warning: format '%li' expects argument of type 'long int', but argument 7 has type 'pthread_t' {aka 'struct __pthread *'} [-Wformat=]
+  117 |                fprintf(log_fp, "%s %s %s[%d.%li]: %s\n", time_buf, hostname,
+      |                                             ~~^
+      |                                               |
+      |                                               long int
+  118 |                        log_ident, getpid(), pthread_self(), message);
+      |                                             ~~~~~~~~~~~~~~
+      |                                             |
+      |                                             pthread_t {aka struct __pthread *}
+logger.c:124:47: warning: format '%li' expects argument of type 'long int', but argument 7 has type 'pthread_t' {aka 'struct __pthread *'} [-Wformat=]
+  124 |                fprintf(stderr, "%s %s %s[%d.%li]: %s\n", time_buf, hostname,
+      |                                             ~~^
+      |                                               |
+      |                                               long int
+  125 |                        log_ident, getpid(), pthread_self(), message);
+      |                                             ~~~~~~~~~~~~~~
+      |                                             |
+      |                                             pthread_t {aka struct __pthread *}
+
+Signed-off-by: Florian Eckert <[email protected]>
+---
+ logger.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/logger.c
++++ b/logger.c
+@@ -115,14 +115,14 @@ void logger(int severity, const char *fm
+           if (log_fp)
+           {
+                fprintf(log_fp, "%s %s %s[%d.%li]: %s\n", time_buf, hostname,
+-                       log_ident, getpid(), pthread_self(), message);
++                       log_ident, getpid(), (unsigned long int) pthread_self(), message);
+                fflush(log_fp);
+           }
+           else if (log_syslog_is_open)
+                syslog(severity, "%s", message);
+           else
+                fprintf(stderr, "%s %s %s[%d.%li]: %s\n", time_buf, hostname,
+-                       log_ident, getpid(), pthread_self(), message);
++                       log_ident, getpid(), (unsigned long int) pthread_self(), message);
+      }
+      va_end(args);
+ }